<!-- 项目附件信息 -->
<template>
  <TCollapse v-if="+showType" title="附件">
    <iframe :src="attachmentInfoUrl" scrolling="no" width="100%" :height="attachmentHeight" frameborder="0" />
  </TCollapse>
  <iframe v-else :src="attachmentInfoUrl" scrolling="no" width="100%" :height="attachmentHeight" frameborder="0" />
</template>
<script>

import TCollapse from '@/components/basic/TCollapse.vue'
import { getQueryObject } from '@/utils'

export default {
  name: 'JnSiteList',
  components: { TCollapse },
  props: {
    prjId: {
      type: String,
      default: '',
      required: true
    },
    showType: {
        type: String,
        default: '1'
    }
  },
  data() {
    return {
      settPageType: '02',
      attachmentHeight: 190
    }
  },
  computed: {
    attachmentInfoUrl() {
        console.log(`${process.env.VUE_APP_ZHONGRUAN_URL}attachDetailList?prjId=${this.prjId}&settPageType=${this.settPageType}`)
      return `${process.env.VUE_APP_ZHONGRUAN_URL}attachDetailList?prjId=${this.prjId}&settPageType=${this.settPageType}`
    }
  },
  async created() {
    const { isPush = '' } = getQueryObject()
    if (+isPush === 0) {
      this.settPageType = '00'
    }
    if (+isPush === 1) {
      this.settPageType = '01'
    }
    window.addEventListener('message', (event) => {
      const base_url = ''
      if (event.origin === base_url) {
        return
      }
      if (event.data.type === 'attachment') {
        console.log('附件传递高度-------', event.data)
        this.attachmentHeight = event.data.height
      }
    })
  }
}
</script>

<style scoped lang='scss'>
</style>
